import java.util.Scanner;

public class Solution {
    private static int[] dp;

    {
        int n = 1690;
        dp = new int[n+1];
        int i2 = 1, i3 = 1, i5 = 1;
        dp[1] = 1;
        for (int i = 1; i < n; ++i) {

            dp[i+1] = Math.min(Math.min(dp[i2]*2, dp[i3]*3), dp[i5]*5);
            if (dp[i+1] == dp[i2]*2) {i2++;}
            if (dp[i+1] == dp[i3]*3) {i3++;}
            if (dp[i+1] == dp[i5]*5) {i5++;}

        }

    }


    public int nthUglyNumber(int n) {

        return dp[n];

    }

    public static int nthUglyNumber2(int n) {
        int[] dp = new int[n];
        dp[0] = 1;
        int i2 = 0, i3 = 0, i5 = 0;
        for (int i = 1; i < n; ++i) {
            int num2 = dp[i2] * 2;
            int num3 = dp[i3] * 3;
            int num5 = dp[i5] * 5;
            dp[i] = Math.min(Math.min(num2, num3), num5);
            if (dp[i] == num2) {i2++;}
            if (dp[i] == num3) {i3++;}
            if (dp[i] == num5) {i5++;}

        }
        return dp[n-1];
    }

    public static int nthUglyNumber3(int n) {
        int[] dp = new int[n + 1];
        dp[1] = 1;
        int p2 = 1, p3 = 1, p5 = 1;
        for (int i = 2; i <= n; i++) {
            int num2 = dp[p2] * 2, num3 = dp[p3] * 3, num5 = dp[p5] * 5;
            dp[i] = Math.min(Math.min(num2, num3), num5);
            if (dp[i] == num2) {
                p2++;
            }
            if (dp[i] == num3) {
                p3++;
            }
            if (dp[i] == num5) {
                p5++;
            }
        }
        return dp[n];
    }



    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(nthUglyNumber2(n));
    }
}
